unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, AYEdit, AYdatetimepicker, ComCtrls, ExtCtrls, Grids,
  DBGrids, DB, DBClient, AYComboBox;

type
  TFormMain = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    Button1: TButton;
    Button2: TButton;
    MemoLog: TMemo;
    DateSFRQ: TAYDateTimePicker;
    EditSFID: TAYEdit;
    EditJE: TAYEdit;
    EditMZH: TAYEdit;
    EditBZ: TAYEdit;
    EditCode: TAYEdit;
    EditDDDH: TAYEdit;
    EditTKJE: TAYEdit;
    DataSource1: TDataSource;
    ClientDataSet1: TClientDataSet;
    DBGrid1: TDBGrid;
    Panel1: TPanel;
    Button3: TButton;
    DateRQ: TAYDateTimePicker;
    ComboBoxLX: TAYComboBox;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormMain: TFormMain;

implementation
uses Pub_ZZGLServer;

{$R *.dfm}

procedure TFormMain.Button1Click(Sender: TObject);
var
  ZZGLServer : TZZGLServer;
  InRec: TCodePayInRec;
  OutRec: TCodePayOutRec;
begin
  InRec.ZFLX := -1;
  InRec.XTLY := 1;
  InRec.SFRQ := Trunc(DateSFRQ.Date);
  InRec.SFID := StrToIntDef(EditSFID.Text,0);
  InRec.JE := StrToFloatDef(EditJE.Text,0.01);
  InRec.Code := EditCode.Text;// '134545453434343654';
  InRec.BLH := EditMZH.Text;
  InRec.BZ := EditBZ.Text;
  InRec.AddList := '';
  InRec.YWIDs := '';
  EditDDDH.Text := '';
  ZZGLServer := TZZGLServer.Create;
  try
    if ZZGLServer.CodePay(InRec,OutRec) then
    begin
      if OutRec.ResultCode <> 0 then
        MemoLog.Lines.Add(OutRec.ErrorMsg)
      else
      begin
        MemoLog.Lines.Add(Format('ResultCode=%d',[OutRec.ResultCode]));
        MemoLog.Lines.Add(Format('ErrorMsg=%s',[OutRec.ErrorMsg]));
        MemoLog.Lines.Add(Format('ZFLX=%d',[OutRec.ZFLX]));
        MemoLog.Lines.Add(Format('DDDH=%s',[OutRec.DDDH]));
        MemoLog.Lines.Add(Format('AddList=%s',[OutRec.AddList]));

        EditDDDH.Text := OutRec.DDDH;
      end;

    end
    else if OutRec.ResultCode <> 0 then
        MemoLog.Lines.Add(OutRec.ErrorMsg);

  finally
    ZZGLServer.Free;
  end;


end;

procedure TFormMain.Button2Click(Sender: TObject);
var
  ZZGLServer : TZZGLServer;
  InRec: TCodePayBackInRec;
  OutRec: TCodePayBackOutRec;
begin
  InRec.DDDH := EditDDDH.Text; //'WX20241206MZSF0000012345';
  InRec.AddList := '';
  InRec.TKJE := StrToFloatDef(EditTKJE.Text,0.01);
  InRec.YWIDs := '';
  ZZGLServer := TZZGLServer.Create;
  try
    if ZZGLServer.CodePayBack(InRec,OutRec) then
    begin
      if OutRec.ResultCode <> 0 then
        MemoLog.Lines.Add(OutRec.ErrorMsg)
      else
      begin
        MemoLog.Lines.Add(Format('ResultCode=%d',[OutRec.ResultCode]));
        MemoLog.Lines.Add(Format('ErrorMsg=%s',[OutRec.ErrorMsg]));
        MemoLog.Lines.Add(Format('ZFLX=%d',[OutRec.ZFLX]));
        MemoLog.Lines.Add(Format('AddList=%s',[OutRec.AddList]));
      end;

    end
    else if OutRec.ResultCode <> 0 then
        MemoLog.Lines.Add(OutRec.ErrorMsg);
  finally
    ZZGLServer.Free;
  end;

end;

procedure TFormMain.FormCreate(Sender: TObject);
begin
  DateSFRQ.Date := Now;
  DateRQ.Date := Now;
end;

procedure TFormMain.Button3Click(Sender: TObject);
var
  ZZGLServer : TZZGLServer;
  InRec: TPayListInRec;
  OutRec: TPayListOutRec;
begin
  InRec.RQ := Trunc(DateRQ.Date); //'WX20241206MZSF0000012345';
  case ComboBoxLX.ItemIndex of
    0 : InRec.LX := 'WX';
    1 : InRec.LX := 'ZF';
  end;

  ZZGLServer := TZZGLServer.Create;
  try
    if ZZGLServer.GetPayList(InRec,OutRec) then
    begin
      if OutRec.ResultCode <> 0 then
        MemoLog.Lines.Add(OutRec.ErrorMsg)
      else
      begin
        MemoLog.Lines.Add(Format('ResultCode=%d',[OutRec.ResultCode]));
        MemoLog.Lines.Add(Format('ErrorMsg=%s',[OutRec.ErrorMsg]));
        ClientDataSet1.Data := OutRec.Data;
      end;

    end
    else if OutRec.ResultCode <> 0 then
        MemoLog.Lines.Add(OutRec.ErrorMsg);
  finally
    ZZGLServer.Free;
  end;

end;

end.
